import http from '@/utils/http';

export default {
    login: (data: HttpPayload.Login): Promise<string> => http<HttpPayload.Login, string>({ url: "/user/login", method: "post", data }),
    getMenu: (): Promise<Array<Vm.Func>> => http({ url: "/user/getmenu", method: "post" }),
    getCategory: ():Promise<Array<Vm.Category>> => http<null,Array<Vm.Category>>({url:"dictionary/all"}),
    getList: (data:HttpPayload.UserSearch): Promise<{total:number; list: Array<Vm.User> }> => http<HttpPayload.UserSearch,{total:number; list: Array<Vm.User>}>({url:"/user/list",method:"post",data}),
    resetPwd:(data:HttpPayload.UserEdit): Promise<null> => http({url:"/user/change_pwd",method:"post",data}),
    add: (data: HttpPayload.UserEdit): Promise<null> => http<HttpPayload.UserEdit, null>({ url: "/user/add", method: "post", data }),
    remove: (user_name: string): Promise<null> => http({ url: "/user/remove/" + user_name, method: "post" }),
    valideName:(data:{user_name:string}): Promise<0 | 1> => http<{user_name:string}, 0 | 1>({url:"/user/valid_name",method:"post",data}),
    roleConfig: (data: HttpPayload.UserRole): Promise<null> => http<HttpPayload.UserRole, null>({ url: "/user/config_role", method: "post", data })
}